package com.yl.androidutilscenter.base.activity

import android.os.Bundle
import android.view.View
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding

/**
 * @author
 * @description: BaseDbActivity,包含dataBinding
 * @date :2024/3/8
 * @version 1.0.0
 */
abstract class BaseDbActivity<VB : ViewDataBinding> : BaseActivity() {
    lateinit var mDataBinding: VB

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val contentView = initDataBind()
        setContentView(contentView)
        initViews(savedInstanceState)
    }

    private fun initDataBind(): View {
        mDataBinding = DataBindingUtil.setContentView(this, layoutId())
        return mDataBinding.root
    }

    /**
     * 设置布局id
     */
    abstract fun layoutId(): Int

    /**
     * 初始化views
     */
    abstract fun initViews(savedInstanceState: Bundle?)

}